package temp

import (
	"background/model/back/entity"
	"gorm.io/gorm"
	"time"
)

type User struct {
	gorm.Model
	Name             string    `gorm:"column:name;comment:'name';type:varchar(255)"   json:"name,omitempty"`
	Email            string    `gorm:"column:email;comment:'email';type:varchar(255)" json:"email"`
	Password         string    `gorm:"column:password;comment:'password';type:varchar(255)" json:"password"`
	Banned           int       `gorm:"column:banned;comment:'是否禁用';type:smallint" json:"banned"`
	PlanID           int       `gorm:"column:plan_id;comment:'订阅项';type:bigint" json:"plan_id"`
	UpTraffic        int       `gorm:"column:up_traffic;comment:'up_traffic';type:varchar(255)" json:"up_traffic"`
	DownTraffic      int       `gorm:"column:down_traffic;comment:'down_traffic';type:varchar(255)" json:"down_traffic"`
	ResetDay         int       `gorm:"column:reset_day;comment:'reset_day';type:smallint" json:"reset_day"`
	ExpiredAt        time.Time `gorm:"column:expired_at;comment:'expired_at';" json:"expired_at"`
	RemainingTraffic int       `gorm:"column:remaining_traffic;comment:'剩余流量单位MB';type:bigint" json:"remaining_traffic"`
	RemindTraffic    int       `gorm:"column:remind_traffic;comment:'流量提醒';type:bool" json:"remind_traffic"`
	RemindExpire     int       `gorm:"column:remind_expire;comment:'过期提醒';type:bool" json:"remind_expire"`
	LastLoginAt      time.Time `gorm:"column:last_login_at;comment:'最后一次登录';" json:"last_login_at"`
}

func (c User) TableName() string {
	return entity.ProjectPre + "user"
}

type UserLoginLog struct {
	gorm.Model
	Email   string `gorm:"column:email;comment:'email';type:varchar(255)" json:"email"`
	IP      int    `gorm:"column:ip;comment:'ip地址';type:varchar(255)" json:"ip"`
	Country string `gorm:"column:country;comment:'国家';type:varchar(255)" json:"country"`
}

func (c UserLoginLog) TableName() string {
	return entity.ProjectPre + "user_log"
}
